/**
 * Created by Administrator on 2016/11/23.
 */

    var sidebar = $("#sidebar");
    var mask = $("#mask");
    var sidebarTriggle = $("#sidebarTriggle");
    var backtop = $("#backtop");

function showsidebar(){
    mask.fadeIn(500);
    sidebar.css('right','0');
}
function hidesidebar(){
    mask.fadeOut(500);
    sidebar.css('right',-sidebar.width());
}
function backtotop(){
    $('html,body').animate({scrollTop:0},500);
}

$(document).ready(function(){
    sidebarTriggle.click(function(){
        showsidebar()
    });
    mask.click(function(){
       hidesidebar()
    });
    backtop.click(function(){
        backtotop()
    });
    $(window).on('scroll',function(){
        if($(window).scrollTop() > $(window).height()){
            backtop.fadeIn();
        }
        else{
            backtop.fadeOut();
        }
    });
    $(window).trigger('scroll');
});